Problem getting fields lists and fields aliases from a frxCustomDataset

Hello, I declare in a function a variable named dataSet, its type is TfrxCustomDataset. The problem is that I'm trying to get the fields names and fields aliases, but when I work with this dataSet variable in a loop, the error Index out of bounds is shown. Originally I have 2 other variables: fieldsAliases and fieldsNames (TStringList).

The procedure I'm using is this one:
procedure TfrmFiltraRelatorio.FormCreate(Sender: TObject);
var
  i: Integer;
  fieldList, fieldAliases : TStringList;
begin
  fieldList    := TStringList.Create;
  fieldAliases := TStringList.Create;

  for i := 0 to Pred(dataSet.FieldsCount) do
    fieldList.Add(dataSet.Fields.Fields[i].FieldName);
end;

Let's assume that this can be replaced by the function dataSet.GetFieldList(fieldList). When I do it, the values of my fieldList's strings receive the fields' aliases actually. I'd like to solve this: get the field's lists and field's aliases in the respective variables. Thanks.

Comments

  • edited 4:45AM
    Did you try (dataSet.FieldsCount - 1) instead of Pred(dataSet.FieldsCount) ?
  • Mick.pl wrote: »
    Did you try (dataSet.FieldsCount - 1) instead of Pred(dataSet.FieldsCount) ?

    Yes Mick, I have the same error :/
  • edited 4:45AM
    Yes Mick, I have the same error :/
    IMO both Fields and FieldDefs generate an error Index out of bounds. And you should send a ticket to FR Team.
    Hava a look at sample code below, maybe it will help you anyway:
    procedure BitBtn1OnClick(Sender: TfrxComponent);
    var
      i: Integer;
    begin
      for i:=0  to ADOQuery1.FieldsCount-1 do with ADOQuery1 do
      begin
        ShowMessage( 'FieldAlias:    ' + FieldAliases[i]        + #13#10 + #13#10 +     
                     'Original name: ' + FieldAliases.Names[i]  + #13#10 +
                     'User name:     ' + FieldAliases.Values[ FieldAliases.Names[i]]);
      end            
    end;
    
    Let us know if they answer your ticket. The solution may be usefull for many FR users.

  • Hi everyone. I was unable to answers the topics this weekend, sorry. Well, I'd like to know how to send a ticket to the development team. Thanks.
  • edited 4:45AM
    Hi everyone. I was unable to answers the topics this weekend, sorry. Well, I'd like to know how to send a ticket to the development team. Thanks.
    Just click "Ticket" on this website http://www.fast-report.com/en/support/
  • Mick.pl wrote: »
    Mick.pl wrote: »
    Hi everyone. I was unable to answers the topics this weekend, sorry. Well, I'd like to know how to send a ticket to the development team. Thanks.
    Just click "Ticket" on this website http://www.fast-report.com/en/support/

    Thnx Mick, here is the link to the ticket http://support.fast-report.com/tickets/251922
  • edited 4:45AM
    wrote:
    Thnx Mick, here is the link to the ticket http://support.fast-report.com/tickets/251922
    All tickets are hidden - no one can see them besides the sender and FR Team >
  • edited February 2013
    Hi everyone! Well, I finally solved my problem. The loop need to be done with a TDataSet component, that is returned when we use the function GetDataSet from some frxDBDataSet. Look at the example:
    for i := 0 to Pred(frxDBDataSet.GetDataSet.FieldsCount) do
        fieldList.Add(frxDBDataSet.GetDataSet.Fields[i].FieldName);
    

    Thanks for the help again! >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.